<?php
/**
* @version		$Id: mod_vinaora_mp3player.php 2010-07-07 vinaora $
* @package		VINAORA MP3 PLAYER
* @copyright	Copyright (C) 2010 VINAORA. All rights reserved.
* @license		GNU/GPL
* @website		http://vinaora.com
* @email		admin@vinaora.com
* 
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

const VINAORA_MP3PLAYER_MEDIA_URL			= 'media/mod_vinaora_mp3player/';
const VINAORA_MP3PLAYER_AJAX_SWFOBJECT_URL	= 'http://ajax.googleapis.com/ajax/libs/swfobject/';

// Require Base Helper
require_once dirname(__FILE__).DS.'helper.php';

// Valid Parameters
$params = modVinaoraMP3PlayerParam::validParams($params);

// Determine config file
$config_dir		= JPATH_BASE.DS.'media'.DS.'mod_vinaora_mp3player'.DS.'config';

$config_custom	= $params->get( 'config_custom' );
$config_name	= $params->get( 'config_code' );

$config_name	= ($config_name) ? $config_name : "demo1.xml.php";
$config_name	= ($config_custom=="-1") ? $config_name : $config_custom;

// Check Config file (.xml) exits and valid XML
$config = modVinaoraMP3PlayerHelper::getConfig($config_dir, $config_name);

// Config File exist and valid
if ( $config ){
}
// Config File not exist
else{
	$xml = modVinaoraMP3PlayerHelper::createXML($params);
	modVinaoraMP3PlayerHelper::createConfig($config_dir, $config_name, $xml);
}

// Initialize variables
$media			= modVinaoraMP3PlayerParam::getBasePath().VINAORA_MP3PLAYER_MEDIA_URL;
$config			= $media.'config/'.$config_name;
$mp3player		= $media.'flash/vinaora_mp3player.swf';
$expressInstall	= $media.'js/swfobject/expressInstall.swf';
$flash_version	= '10.0.0';

$skin			= $media.'skins/'.$params->get('skin').'/skin.xml';
$width			= $params->get('width');
$height			= $params->get('height');

$module_id		= $module->id;
$container		= 'mod_vinaora_mp3player_container'.$module_id;
$player			= 'mod_vinaora_mp3player_'.$module_id;

// Add SWFObject Library to <head> tag
modVinaoraMP3PlayerParam::addSWFObject($params->get('swfobject'));

// Load Default Layout
require(JModuleHelper::getLayoutPath('mod_vinaora_mp3player'));
